package com.yn.pet.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum FenceAlarmTypeEnum {
    // 进入，code 对应 1
    ENTER( 1, "进围栏报警"),
    // 离开，code 对应 2
    LEAVE( 2,  "出围栏报警");

    private Integer code;
    private String name;

    public static FenceAlarmTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (FenceAlarmTypeEnum alarmType : FenceAlarmTypeEnum.values()) {
            if (alarmType.getCode().equals(code)) {
                return alarmType;
            }
        }
        return null;
    }
}